var getinfo = function(){

    //获取问题的答案以及追问追答的内容
    $.ajax({
        type : "POST",
        url : WebSite.ReplyerUnansweredPage.searchquestion_detail,
        dateType : "json",
        data:{
            "pk_question":getUrlParam("pk_question")
        },
        success : function(result){
            var myTemplate = Handlebars.compile($("#handling-template").html());
            $("#left_info_div").html(myTemplate(result));
        },
        error : function () {
            alert("问题的详细信息未获取到");
        }
    });

};

//改变时间格式
Handlebars.registerHelper("transdate", function(str,options) {
    return new Date(parseInt(str)).toLocaleString();
});


//提交答案
var submitAnswer = function(){
    var submitFormOptions = {
        url          : WebSite.ReplyerUnansweredPage.commitAnswer,
        type         : "post",
        dataType     : "json",
        data         : {
        "pk_sool_question" : getUrlParam("pk_question")
        },
        beforeSubmit : function(){
            if($("#contentEditor").text() == ""){
                alert("提交的答案不能为空");
                return false;
            };
        },
        success : function(result){
            if(result.success){
                console.log(result.resultData);
                var myTemplate = Handlebars.compile($("#addMyAnswer").html());
                $("#answerDetail").append(myTemplate(result));
                location.reload();
                $("#contentEditor").html("");
                $("#submitQuestion").hide();
            }else{
                if(result.statusCode == '001'){
                    $("#poplayer").css("display","block");
                    $("#poplayer").css("position","fixed");
                    $("#covered").show();
                }else{
                    alert(result.msg);
                }

            }
        },
        error : function(){
            alert("提交答案未成功");
        }
    };
    $("#firstAnswerInfo").ajaxForm(submitFormOptions);
}

//显示回答人的类型
Handlebars.registerHelper("transtype", function(type, options){
    if(type == 1){
        return options.fn(this);
    }else if(type == 2){
        return options.inverse(this);
    }
});

//弹出附件上传
function getUpload(){
    $(".uploadDisplay").addClass("uploadDisplay-block");
};
